package com.qidian.mes.md.service.impl;

import com.qidian.mes.md.mapper.UnitMapper;
import com.qidian.mes.md.service.UnitService;
import com.qidian.mes.pojo.Unit;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.swing.*;
import java.util.List;

/**
 * @Author: 小可怎么都睡不够
 * @Description:
 * @Time: 2024-04-07 14:56
 **/
@Service
public class UnitServiceImpl implements UnitService {
    @Autowired
    UnitMapper unitMapper;

    @Override
    public QdResult findAll(Integer page, Integer limit) {
        return QdResult.success(unitMapper.findAll((page - 1) * limit, limit));
    }

    @Override
    public QdResult findByName(String name, Integer page, Integer limit) {
        return QdResult.success(unitMapper.findByName(name, (page - 1) * limit, limit));
    }

    @Override
    public QdResult add(Unit unit) {
        unitMapper.add(unit);
        return QdResult.success();
    }

    @Override
    public QdResult updateStatus(Integer id, Integer status) {
        unitMapper.updateStatus(id,status);
        return QdResult.success();
    }

    @Override
    public QdResult update(Unit unit) {
        unitMapper.update(unit);
        return QdResult.success();
    }

    @Override
    public QdResult noPagesFindAll() {
        return QdResult.success(unitMapper.noPagesFindAll());
    }

    @Override
    public QdResult getCount() {

        return QdResult.success(unitMapper.getCount());
    }

}
